using System;

namespace EnsoDeveloperExtension.SampleApp.Test
{
    class TestCommand : EnsoCommand
    {
        public override string Name
        {
            get { return "caesar"; }
        }

        public override string Description
        {
            get { return "encrypts the selected text with the caesar encryption."; }
        }

        public override string Help
        {
            get { return "<p>there is no help</p>"; }
        }

        public override void Call(string postfix)
        {
            string selectedText = GetUniCodeSelection();
            if (String.IsNullOrEmpty(selectedText))
            {
                DisplayMessage("<p>No text selected.</p>");
                return;
            }

            SetUnicodeSelection(Caesarize(selectedText));
        }

        private string Caesarize(string text)
        {
            string output = String.Empty;
            foreach (char c in text)
            {
                output += (char) (c + 1);
            }
            return output;
        }
    }
}
